home *** CD-ROM | disk | FTP | other *** search
/ Birds of My State or Province 4.5 / eField Guide Viewer.iso / pc / Windows / CR115.cab / preview.asp.9EEF3408_6D73_4CDA_9C48_00AC83DAE200 < prev    next >
Encoding:
Text File  |  2005-05-13  |  2.9 KB  |  87 lines

  1. <%@ Language=VBScript codepage=65001%>
  2.  
  3. <% Option Explicit
  4. Response.ExpiresAbsolute = Now() - 1
  5. const CLOSED_RPT_ID = "closedreportid"
  6. const RPT_ID = "reportid"
  7. const RPT_SOURCE = "reportsource"
  8.  
  9. Dim requestMethod
  10. requestMethod = UCase(Request.ServerVariables("REQUEST_METHOD"))
  11.  
  12. Dim serializedRptSrc, reportid, closedreportid
  13. if (requestMethod = "POST") then
  14.     serializedRptSrc = Request.Form(RPT_SOURCE)
  15.     closedreportid = Request.Form(CLOSED_RPT_ID)
  16. else
  17.     serializedRptSrc = Request.QueryString(RPT_SOURCE)
  18.     closedreportid = Request.QueryString(CLOSED_RPT_ID)
  19. end if
  20.  
  21. ' reportid is always passed in the URL
  22. reportid = Request.QueryString(RPT_ID)
  23.  
  24. if (Not (IsEmpty(closedreportid) OR (Len(closedreportid) = 0))) then
  25.     ' Clear the report source in session with the given closedreportid
  26.     Session.Contents.Remove(closedreportid)
  27. end if
  28.  
  29. if (Not (IsEmpty(reportid) OR (Len(reportid) = 0))) then
  30.     On Error Resume Next
  31.  
  32.     Dim objectFactory
  33.     ' Use the version dependent prog id for side by side support
  34.     ' (i.e. to maintain consistency when multiple versions of the product is installed)
  35.     Set objectFactory = CreateObject("CrystalReports115.ObjectFactory.1")
  36.  
  37.     Dim HTMLViewer
  38.  
  39.     Set HTMLViewer = ObjectFactory.CreateObject("CrystalReports.CrystalReportViewer")
  40.     With HTMLViewer
  41.         .Name = "htmlpreview"
  42.         .IsOwnForm = true
  43.         .IsOwnPage = true
  44.         .HasRefreshButton = false
  45.         .HasExportButton = false
  46.         .HasPrintButton = false
  47.     End With
  48.  
  49.     Dim errorHeader
  50.     Dim errorMessage
  51.         
  52.     if (Not (IsEmpty(serializedRptSrc) OR (Len(serializedRptSrc) = 0))) then
  53.         ' Got a seralizedRprtSrc string
  54.         ' need to deserialize the report source string and pass to viewer
  55.         Dim XMLSerializer
  56.         Set XMLSerializer = ObjectFactory.CreateObject("CrystalReports.SAXXMLSerializer")
  57.  
  58.         XMLSerializer.SetObjectCreator ObjectFactory
  59.         HTMLViewer.ReportSource = XMLSerializer.CreateObjectFromString(serializedRptSrc)
  60.  
  61.         set Session.Contents(reportid) = HTMLViewer.ReportSource
  62.     else
  63.     ' Try to load report source from session
  64.         HTMLViewer.ReportSource = Session.Contents(reportid)
  65.         if (IsEmpty(HTMLViewer.ReportSource)) then
  66.             errorHeader = "L_SessionExpired"
  67.             errorMessage = "L_PleaseRefresh"
  68.         end if
  69.     end if
  70.  
  71.     if (IsEmpty(errorHeader)) then
  72.         HTMLViewer.URI = Request.ServerVariables("Path_Info") + "?" + RPT_ID + "=" + reportid
  73.     
  74.         call HTMLViewer.ProcessHttpRequest(Request, Response, Session)
  75.         if Err.number <> 0 then
  76.             Response.Write Err.Description
  77.             Err.Clear
  78.         end if
  79.     else
  80.         Response.Write "<script language=""javascript"" src=""js/previewerror.js""></script>"
  81.         Response.Write "<script>writeError(" & errorHeader & "," & errorMessage & ");</script>"
  82.     end if
  83.     
  84. end if
  85.  
  86. %>
  87.